<template>
    <div v-if="show" class="userInfoShowrootmain">
        <el-form
            class="personalData"
            :label-position="labelPosition"
            label-width="98px"
            :model="formLabelAlign"
        >
            <el-form-item class="formItem flex-align">
                <template slot="label">头&emsp;&emsp;像</template>
                <div class="avatarImg">
                    <img
                        class="img100 cover"
                        :src="userInfo && userInfo.avatar"
                        alt=""
                    />
                </div>
            </el-form-item>
            <el-form-item class="flex" label="昵称">
                <template slot="label">昵&emsp;&emsp;称</template>
                <div class="nickName c666">
                    {{ userInfo && userInfo.nickname }}
                </div>
            </el-form-item>
            <el-form-item class="flex" label="手机号码">
                <div class="c666">
                    {{
                        userInfo &&
                        userInfo.mobile.slice(0, 3) +
                            "****" +
                            userInfo.mobile.slice(7, 11)
                    }}
                </div>
            </el-form-item>
            <el-form-item class="flex" label="">
                <template slot="label">邮&emsp;&emsp;箱</template>
                <div class="c666">{{ userInfo && userInfo.email }}</div>
            </el-form-item>
            <el-form-item class="flex" label="">
                <template slot="label">所在地区</template>
                <div class="c666">{{ userInfo && userInfo.belong_area }}</div>
            </el-form-item>
            <el-form-item class="flex" label="">
                <template slot="label">所属行业</template>
                <div class="c666">{{ userInfo && userInfo.belong_trade }}</div>
            </el-form-item>
            <el-form-item class="flex" label="" label-width="217px">
                <template slot="label">感兴趣的税种（最多选3个）</template>
                <div class="c666">{{ userInfo && userInfo.belong_tax }}</div>
            </el-form-item>
            <el-form-item class="flex" label="个人介绍">
                <div class="c666">{{ userInfo && userInfo.bio }}</div>
            </el-form-item>
            <el-form-item class="flex" label="角色">
                <div v-if="userInfo" class="c666">
                    {{ position[userInfo.position - 1] }}
                </div>
            </el-form-item>
            <el-form-item
                v-if="userInfo && userInfo.is_major == 1"
                class="flex"
                label="专业方向"
            >
                <div v-if="userInfo && userInfo.major_direction" class="tags">
                    <div
                        v-for="(item, index) in userInfo &&
                        userInfo.major_direction.split(',')"
                        :key="index"
                    >
                        {{ item }}
                    </div>
                </div>
            </el-form-item>

            <div class="edit c666 fz14" @click="changePage()">
                <i class="el-icon-edit"></i>
                <span>编辑</span>
            </div>
        </el-form>
    </div>
</template>

<script>
import { mapState, mapMutations } from "vuex";

export default {
    data() {
        return {
            labelPosition: "right",
            formLabelAlign: {
                name: "",
                region: "",
                type: "",
            },
            position: ["会计", "出纳", "主管", "经理", "总监", "老板"],
            show: false,
        };
    },
    computed: {
        ...mapState("userCenter", {
            showInfo: (state) => state.showInfo,
        }),
        ...mapState("common", {
            userInfo: (state) => state.userInfo,
        }),
    },
    mounted() {
        console.log(this.showInfo);
        this.show = true;
    },
    methods: {
        changePage() {
            this.setshowInfo(false);
        },
        ...mapMutations("userCenter", ["setshowInfo"]),
    },
};
</script>

<style lang="scss" scoped>
@import url("@/assets/static/iconfont.css");
@import url("@/assets/static/reset.css");

.userInfoShowrootmain {
    background-color: #fff;
    margin-left: 20px;
    margin-bottom: 20px;
    min-height: 460px;
    .personalData {
        position: relative;
        // margin-top: 30px;
        padding: 30px;
        background-color: #fff;

        .avatarImg {
            width: 68px;
            height: 68px;
            position: relative;
            border-radius: 50%;
            overflow: hidden;
        }
        .nickName {
            color: #666666;
        }

        ::v-deep .el-form-item__content {
            margin-left: 40px !important;
        }

        ::v-deep.el-form-item__label {
            color: #333;
            min-width: 98px;
        }
    }
    .edit {
        cursor: pointer;
        position: absolute;
        top: 63px;
        right: 85px;
    }

    &::v-deep .el-form-item__label {
        color: #333;
        min-width: 98px;
    }

    .cover {
        object-fit: cover;
    }

    .tags {
        display: flex;
        flex-wrap: wrap;
        div {
            line-height: 31px;
            height: 31px;
            text-align: center;
            border-radius: 2px;
            border: 1px solid #333333;
            padding: 0 14px;
            margin-right: 5px;
            margin-bottom: 5px;
            cursor: pointer;
        }
    }
}
</style>